package utils

import (
	"encoding/json"
	"fmt"
)

const (
	url = "http://local.nest.cn"
)

type api struct {
	Login              string
	CheckVersionNumber string
	UpdatePackage      string
	Versions           string
	Metadata           string
}

var Api = api{
	Login:              url + "/login",
	CheckVersionNumber: url + "/pkg/checkVersionNumber",
	UpdatePackage:      url + "/pkg/updatePackage",
	Versions:           url + "/openpkg/versions",
	Metadata:           url + "/openpkg/metadata",
}

type Response struct {
	Success bool        `json:"success"`
	Code    int         `json:"code"`
	Msg     string      `json:"msg"`
	Data    interface{} `json:"data"`
}

func ReturnFun(result string) Response {
	var resp Response
	err := json.Unmarshal([]byte(result), &resp)
	if err != nil {
		fmt.Println("转换失败", err)
	}
	return resp
}
